﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Qianli.DirSir.Common;
using Qianli.DirSir.Model;
using System.Data;

namespace Qianli.DirSir.DAL
{
    public class OrderInfoDAL
    {
        SQLHelper sqlhelper = new SQLHelper();
        public List<OrderInfo> ShowOrderInfo()
        {
            string sql = "select ";
            sql += "  OrderID,StorehouseInfo.StorehouseName,StoreInfo.StoreName,DHLUPSFEDEXEMSInfo.DHLUPSFEDEXEMSName,Userinfo.UserName,CustomersInfo.CustomersName,OrderCoding,orderInfo.Remarks,InOrderTime ";
            sql += "  from orderInfo  join StorehouseInfo on OrderInfo.StorehouseID=StorehouseInfo.StorehouseID ";
            sql += "  join StoreInfo on OrderInfo.StoreID=StoreInfo.StoreID ";
            sql += "  join DHLUPSFEDEXEMSInfo on OrderInfo.DHLUPSFEDEXEMSID=DHLUPSFEDEXEMSInfo.DHLUPSFEDEXEMSID ";
            sql += "  join Userinfo on OrderInfo.UserID=Userinfo.UserID ";
            sql += "  join CustomersInfo on OrderInfo.CustomersID=CustomersInfo.CustomersID";
            DataTable dt = sqlhelper.ExecDataTable(sql);
            List<OrderInfo> list = new List<OrderInfo>();
            foreach (DataRow item in dt.Rows)
            {
                OrderInfo OrderInfo = new OrderInfo();
                OrderInfo.OrderID = Convert.ToInt32(item["OrderID"]);
                OrderInfo.StorehouseName = item["StorehouseName"].ToString();
                OrderInfo.StoreName = item["StoreName"].ToString();
                OrderInfo.DHLUPSFEDEXEMSName = item["DHLUPSFEDEXEMSName"].ToString();
                OrderInfo.UserName = item["UserName"].ToString();
                OrderInfo.CustomersName = item["CustomersName"].ToString();
                OrderInfo.OrderCoding = item["OrderCoding"].ToString();
                OrderInfo.Remarks = item["Remarks"].ToString();
                OrderInfo.InOrderTime = Convert.ToDateTime(item["InOrderTime"]);
                list.Add(OrderInfo);
            }
            return list;
        }
    }
}
